<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/base.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/info-mgt.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/info-reg.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/WdatePicker.css" />
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/common.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/WdatePicker.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.pagination.js"></script>
		<title>移动办公自动化系统</title>
		<script type="text/javascript">
	$(function() {
		$.ajax( {
			type : "post",
			url : "WorkManager.action?method=query",
			success : function(obj) {
				var tbodyObj = document.createElement("tbody");
				tbodyObj.id = "body_id";
				var tableObj = document.getElementById("data_id");
				tableObj.appendChild(tbodyObj);
				var fd = obj.dayofweek;
				var days = obj.maxday;
				var t = 1;
				var min = obj.min;
				var max = obj.max;
				var year = obj.year;
				var month = obj.month;
				$("#ym").text(year+"年"+month+"月");
				for ( var i = 0; i < 6; i++) {
					var trObj = document.createElement("tr");
					if (fd == 1) {
						var td_sun = document.createElement("td");
						if (t <= days) {
							td_sun.innerHTML = t;
							td_sun.id = "sun" + t;
							t += 1;
						}
						var td_mon = document.createElement("td");
						if (t <= days) {
							td_mon.innerHTML = t;
							td_mon.id = "mon" + t;
							t += 1;
						}
						var td_tue = document.createElement("td");
						if (t <= days) {
							td_tue.innerHTML = t;
							td_tue.id = "tue" + t;
							t += 1;
						}
						var td_wed = document.createElement("td");
						if (t <= days) {
							td_wed.innerHTML = t;
							td_wed.id = "wed" + t;
							t += 1;
						}
						var td_thu = document.createElement("td");
						if (t <= days) {
							td_thu.innerHTML = t;
							td_thu.id = "thu" + t;
							t += 1;
						}
						var td_fri = document.createElement("td");
						if (t <= days) {
							td_fri.innerHTML = t;
							td_fri.id = "fri" + t;
							t += 1;
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					if (fd == 2) {
						var td_sun = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_sun.innerHTML = t;
								td_sun.id = "sun" + t;
								t += 1;
							}
						}
						var td_mon = document.createElement("td");
						if (t <= days) {
							td_mon.innerHTML = t;
							td_mon.id = "mon" + t;
							t += 1;
						}
						var td_tue = document.createElement("td");
						if (t <= days) {
							td_tue.innerHTML = t;
							td_tue.id = "tue" + t;
							t += 1;
						}
						var td_wed = document.createElement("td");
						if (t <= days) {
							td_wed.innerHTML = t;
							td_wed.id = "wed" + t;
							t += 1;
						}
						var td_thu = document.createElement("td");
						if (t <= days) {
							td_thu.innerHTML = t;
							td_thu.id = "thu" + t;
							t += 1;
						}
						var td_fri = document.createElement("td");
						if (t <= days) {
							td_fri.innerHTML = t;
							td_fri.id = "fri" + t;
							t += 1;
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					if (fd == 3) {
						var td_sun = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_sun.innerHTML = t;
								td_sun.id = "sun" + t;
								t += 1;
							}
						}
						var td_mon = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_mon.innerHTML = t;
								td_mon.id = "mon" + t;
								t += 1;
							}
						}
						var td_tue = document.createElement("td");
						if (t <= days) {
							td_tue.innerHTML = t;
							td_tue.id = "tue" + t;
							t += 1;
						}
						var td_wed = document.createElement("td");
						if (t <= days) {
							td_wed.innerHTML = t;
							td_wed.id = "wed" + t;
							t += 1;
						}
						var td_thu = document.createElement("td");
						if (t <= days) {
							td_thu.innerHTML = t;
							td_thu.id = "thu" + t;
							t += 1;
						}
						var td_fri = document.createElement("td");
						if (t <= days) {
							td_fri.innerHTML = t;
							td_fri.id = "fri" + t;
							t += 1;
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					if (fd == 4) {
						var td_sun = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_sun.innerHTML = t;
								td_sun.id = "sun" + t;
								t += 1;
							}
						}
						var td_mon = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_mon.innerHTML = t;
								td_mon.id = "mon" + t;
								t += 1;
							}
						}
						var td_tue = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_tue.innerHTML = t;
								td_tue.id = "tue" + t;
								t += 1;
							}
						}
						var td_wed = document.createElement("td");
						if (t <= days) {
							td_wed.innerHTML = t;
							td_wed.id = "wed" + t;
							t += 1;
						}
						var td_thu = document.createElement("td");
						if (t <= days) {
							td_thu.innerHTML = t;
							td_thu.id = "thu" + t;
							t += 1;
						}
						var td_fri = document.createElement("td");
						if (t <= days) {
							td_fri.innerHTML = t;
							td_fri.id = "fri" + t;
							t += 1;
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					if (fd == 5) {
						var td_sun = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_sun.innerHTML = t;
								td_sun.id = "sun" + t;
								t += 1;
							}
						}
						var td_mon = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_mon.innerHTML = t;
								td_mon.id = "mon" + t;
								t += 1;
							}
						}
						var td_tue = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_tue.innerHTML = t;
								td_tue.id = "tue" + t;
								t += 1;
							}
						}
						var td_wed = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_wed.innerHTML = t;
								td_wed.id = "wed" + t;
								t += 1;
							}
						}
						var td_thu = document.createElement("td");
						if (t <= days) {
							td_thu.innerHTML = t;
							td_thu.id = "thu" + t;
							t += 1;
						}
						var td_fri = document.createElement("td");
						if (t <= days) {
							td_fri.innerHTML = t;
							td_fri.id = "fri" + t;
							t += 1;
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					if (fd == 6) {
						var td_sun = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_sun.innerHTML = t;
								td_sun.id = "sun" + t;
								t += 1;
							}
						}
						var td_mon = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_mon.innerHTML = t;
								td_mon.id = "mon" + t;
								t += 1;
							}
						}
						var td_tue = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_tue.innerHTML = t;
								td_tue.id = "tue" + t;
								t += 1;
							}
						}
						var td_wed = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_wed.innerHTML = t;
								td_wed.id = "wed" + t;
								t += 1;
							}
						}
						var td_thu = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_thu.innerHTML = t;
								td_thu.id = "thu" + t;
								t += 1;
							}
						}
						var td_fri = document.createElement("td");
						if (t <= days) {
							td_fri.innerHTML = t;
							td_fri.id = "fri" + t;
							t += 1;
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					if (fd == 7) {
						var td_sun = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_sun.innerHTML = t;
								td_sun.id = "sun" + t;
								t += 1;
							}
						}
						var td_mon = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_mon.innerHTML = t;
								td_mon.id = "mon" + t;
								t += 1;
							}
						}
						var td_tue = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_tue.innerHTML = t;
								td_tue.id = "tue" + t;
								t += 1;
							}
						}
						var td_wed = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_wed.innerHTML = t;
								td_wed.id = "wed" + t;
								t += 1;
							}
						}
						var td_thu = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_thu.innerHTML = t;
								td_thu.id = "thu" + t;
								t += 1;
							}
						}
						var td_fri = document.createElement("td");
						if (i > 0) {
							if (t <= days) {
								td_fri.innerHTML = t;
								td_fri.id = "fri" + t;
								t += 1;
							}
						}
						var td_sat = document.createElement("td");
						if (t <= days) {
							td_sat.innerHTML = t;
							td_sat.id = "sat" + t;
							t += 1;
						}
					}
					//把td添加到对应的tr中
			trObj.appendChild(td_sun);
			trObj.appendChild(td_mon);
			trObj.appendChild(td_tue);
			trObj.appendChild(td_wed);
			trObj.appendChild(td_thu);
			trObj.appendChild(td_fri);
			trObj.appendChild(td_sat);
			//把tr对象添加到tbody中
			tbodyObj.appendChild(trObj);
		}
		if(min==1){
			for(var i=0;i<t;i++){
				$("#mon"+i).css("color","blue");		
			}
		}
		if(max==7){
			for(var i=0;i<t;i++){
				$("#sun"+i).css("color","blue");		
			}
		}
		if(min<=2 && max>=2){
			for(var i=0;i<t;i++){
				$("#tue"+i).css("color","blue");		
			}
		}
		if(min<=3 && max>=3){
			for(var i=0;i<t;i++){
				$("#wed"+i).css("color","blue");		
			}
		}
		if(min<=4 && max>=4){
			for(var i=0;i<t;i++){
				$("#thu"+i).css("color","blue");		
			}
		}
		if(min<=5 && max>=5){
			for(var i=0;i<t;i++){
				$("#fri"+i).css("color","blue");		
			}
		}
		if(min<=6 && max>=6){
			for(var i=0;i<t;i++){
				$("#sat"+i).css("color","blue");		
			}
		}
		var timelist = obj.timelist;
		var typelist = obj.typelist;
		var timeval=null;
		var typeval=null;
		for(var i=0;i<timelist.length;i++){
			timeval = timelist[i].split("-");
			typeval = typelist[i];
			year = timeval[0];
			month = parseInt(timeval[1]);
			days = parseInt(timeval[2]);
			if(year == obj.year){
				if(month == obj.month){
					if(typeval == "请假"){
								$("#mon"+days).css("color","green");
								$("#tue"+days).css("color","green");
								$("#wed"+days).css("color","green");
								$("#thu"+days).css("color","green");
								$("#fri"+days).css("color","green");
								$("#sat"+days).css("color","green");		
					}else if(typeval == "加班"){
								$("#mon"+days).css("color","red");
								$("#tue"+days).css("color","red");
								$("#wed"+days).css("color","red");
								$("#thu"+days).css("color","red");
								$("#fri"+days).css("color","red");
								$("#sat"+days).css("color","red");
					}
				}
			}
		}
	
	}
		});
	});
</script>
		<style>
.work {
	position: absolute;
	font-size: 22px;
	left: 100px;
	top: 400px;
}

.extra {
	position: absolute;
	font-size: 22px;
	left: 400px;
	top: 400px;
}

.holiday {
	position: absolute;
	font-size: 22px;
	left: 700px;
	top: 400px;
}

.wimg {
	background-color: blue;
	position: absolute;
	left: 190px;
	top: 400px;
	width: 100px;
	height: 30px;
}

.eimg {
	background-color: red;
	position: absolute;
	left: 490px;
	top: 400px;
	top: 400px;
	width: 100px;
	height: 30px;
}

.himg {
	background-color: green;
	position: absolute;
	left: 790px;
	top: 400px;
	top: 400px;
	width: 100px;
	height: 30px;
}
.tsize td{font-size:26px;font-family:'楷体';}
</style>
	</head>

	<body>
		<div class="title">
			<h2>
				工作时间
			</h2>
		</div>

		<table id="data_id" class="tsize">
			<thead>
				<tr>
					<th>
						星期天
					</th>
					<th>
						星期一
					</th>
					<th>
						星期二
					</th>
					<th>
						星期三
					</th>
					<th>
						星期四
					</th>
					<th>
						星期五
					</th>
					<th>
						星期六
					</th>
				</tr>
			</thead>
		</table>
		<div id="ym" style="text-align: center; margin: 0 auto; font-size: 30px;">
		</div>
		<div class="work">
			工作日:
		</div>
		<div class="wimg"></div>
		<div class="extra">
			加班:
		</div>
		<div class="eimg"></div>
		<div class="holiday">
			请假:
		</div>
		<div class="himg"></div>
	</body>
</html>


